package com.yn.common.response.zy;


import com.yn.common.constants.Constants;
import com.yn.common.enums.AppointmentStatusEnum;
import com.yn.common.enums.BusinessTypeEnum;
import com.yn.common.model.zy.SubscribeInfoDO;
import com.yn.common.request.zy.ApptAddInfoRequest;
import com.yn.common.utils.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="普通预约和急诊预约返回对象", description="普通预约和急诊预约")
public class DiagnosisInfoResponse {

    @ApiModelProperty(value = "预约id")
    private Integer id;

    @ApiModelProperty(value = "关联id")
    private Integer businessId;

    //业务类型(0:普通预约 1:急诊预约 2:机构预约)
    @ApiModelProperty(value = "业务类型")
    private Integer businessType;

    @ApiModelProperty(value = "业务类型字符串")
    private String businessTypeStr;

    // 专家名称
    @ApiModelProperty(value = "专家名称")
    private String doctorName;

    // 医院名称
    @ApiModelProperty(value = "医院名称")
    private String hospitalName;

    // 真实姓名（就诊人姓名）
    @ApiModelProperty(value = "真实姓名")
    private String userOrderName;

    // 手机号码
    @ApiModelProperty(value = "手机号码")
    private String userOrderPhone;

    // 身份证号
    @ApiModelProperty(value = "身份证号")
    private String idCard;

    // 居住地址
    @ApiModelProperty(value = "居住地址")
    private String residenceAddress;

    // 疾病名称
    @ApiModelProperty(value = "疾病名称")
    private String diseaseName;

    //预约时间
    @ApiModelProperty(value = "预约时间")
    @NotBlank(message = "预约时间不能为空")
    private String apptTime;

    @ApiModelProperty(value = "状态")
    private Integer status;

    @ApiModelProperty(value = "状态字符串")
    private String statusStr;


    @ApiModelProperty(value = "创建人id")
    private Integer appUserId;

    @ApiModelProperty(value = "更新人id")
    private Integer updateUserId;

    @ApiModelProperty(value = "创建时间")
    private String createTime;

    @ApiModelProperty(value = "更新时间")
    private String updateTime;

    // 备注信息
    @ApiModelProperty(value = "备注信息")
    private String remark;

    public static DiagnosisInfoResponse transform(SubscribeInfoDO infoDO) {
        DiagnosisInfoResponse response = new DiagnosisInfoResponse();

        response.setId(infoDO.getId());
        response.setBusinessId(infoDO.getBusinessId());
        response.setUserOrderName(infoDO.getUserOrderName());
        response.setUserOrderPhone(infoDO.getUserOrderPhone());
        response.setIdCard(infoDO.getIdCard());
        response.setResidenceAddress(infoDO.getResidenceAddress());
        response.setDiseaseName(infoDO.getDiseaseName());
        response.setApptTime(DateUtil.dateToStr(infoDO.getApptTime(), Constants.DATE_FORMAT));
        response.setBusinessType(infoDO.getBusinessType());
        response.setAppUserId(infoDO.getAppUserId());
        response.setUpdateUserId(infoDO.getUpdateUserId());
        response.setCreateTime(DateUtil.dateToStr(infoDO.getCreateTime(), Constants.DATE_FORMAT));
        response.setUpdateTime(DateUtil.dateToStr(infoDO.getUpdateTime(), Constants.DATE_FORMAT));
        response.setStatus(infoDO.getStatus());
        response.setBusinessTypeStr(BusinessTypeEnum.getByCode(infoDO.getBusinessType()).getName());
        response.setStatusStr(AppointmentStatusEnum.getByCode(infoDO.getStatus()).getName());
        if(infoDO.getRemark() != null){
            response.setRemark(infoDO.getRemark());
        }
        return response;
    }
}
